﻿using BaiTu.IEventServices;
using BaiTu.IQueueService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BaiTu.IOCServices;
using BaiTu.EventServices.Helpers;
using BaiTu.EventEntity;

namespace BaiTu.EventServices
{
    public class EventResolver : IEventResolver
    {
        private IQueue queueSrv = EngineContext.Current.Resolve<IQueue>();

        /// <summary>
        /// 解析传入的消息，解析后发到消息队列中
        /// </summary>
        /// <param name="msg"></param>
        public void Resolve(string msg)
        {
            string evtClassPath;
            string evtXml;
            if (EventHelper.IsEventBusCommand_Publish(msg, out evtClassPath, out evtXml))
            {
                //send to queue
                EventInfo info = new EventInfo();                
                info.Xml = evtXml;
                queueSrv.SendRequestToWorker<EventInfo>(info);
            }
        }
    }
}
